package main

import (
	"fmt"
	"io/ioutil"
	"math/rand"
	"os"
	"time"
)

// random 获取随机数
func random() string {
	rand.Seed(time.Now().UnixNano())
	r := fmt.Sprint(rand.Float64())
	if len(r) > 18 {
		r = r[:18]
	}
	return r
}

// WriteFile 写文件。
func WriteFile(data []byte, path, filename string) error {
	_, err := os.Stat(path)
	if err != nil {
		_ = os.Mkdir(path, 0777)
	}
	return ioutil.WriteFile(path + filename, data, 0777)
}

// ReadFile 读文件
func ReadFile(filename string) ([]byte, error) {
	 return ioutil.ReadFile(filename)
}